package com.zhengbing.tj.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDateTime;

/**
 * 权限实体类
 * 定义系统中的功能权限信息
 *
 * @author zhengbing
 * @date 2024-08-22
 */
@TableName("permission")
@Api(tags = "权限")
public class Permission extends Model<Permission> {
    /**
     * 权限ID
     */
    @ApiModelProperty(value = "权限ID", example = "123456789012345678")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    
    /**
     * 权限名称
     */
    @ApiModelProperty(value = "权限名称", example = "查看用户列表")
    private String name;
    
    /**
     * 权限标识
     */
    @ApiModelProperty(value = "权限标识", example = "user:list")
    private String code;
    
    /**
     * 权限类型
     * 0: 菜单权限
     * 1: 按钮权限
     * 2: 接口权限
     */
    @ApiModelProperty(value = "权限类型", example = "0")
    private Integer type;
    
    /**
     * 父权限ID
     */
    @ApiModelProperty(value = "父权限ID", example = "0")
    private Long parentId;
    
    /**
     * 资源路径（如API路径）
     */
    @ApiModelProperty(value = "资源路径", example = "/api/users")
    private String path;
    
    /**
     * 请求方法
     */
    @ApiModelProperty(value = "请求方法", example = "GET")
    private String method;
    
    /**
     * 图标
     */
    @ApiModelProperty(value = "图标", example = "icon-user")
    private String icon;
    
    /**
     * 排序
     */
    @ApiModelProperty(value = "排序", example = "1")
    private Integer sort;
    
    /**
     * 是否可见
     */
    @ApiModelProperty(value = "是否可见", example = "1")
    private Integer visible;
    
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    private LocalDateTime updateTime;
    
    // 无参构造函数
    public Permission() {
    }
    
    // 全参构造函数
    public Permission(Long id, String name, String code, Integer type, Long parentId, 
                     String path, String method, String icon, Integer sort, 
                     Integer visible, LocalDateTime createTime, LocalDateTime updateTime) {
        this.id = id;
        this.name = name;
        this.code = code;
        this.type = type;
        this.parentId = parentId;
        this.path = path;
        this.method = method;
        this.icon = icon;
        this.sort = sort;
        this.visible = visible;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
    
    // getter和setter方法
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getCode() {
        return code;
    }
    
    public void setCode(String code) {
        this.code = code;
    }
    
    public Integer getType() {
        return type;
    }
    
    public void setType(Integer type) {
        this.type = type;
    }
    
    public Long getParentId() {
        return parentId;
    }
    
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }
    
    public String getPath() {
        return path;
    }
    
    public void setPath(String path) {
        this.path = path;
    }
    
    public String getMethod() {
        return method;
    }
    
    public void setMethod(String method) {
        this.method = method;
    }
    
    public String getIcon() {
        return icon;
    }
    
    public void setIcon(String icon) {
        this.icon = icon;
    }
    
    public Integer getSort() {
        return sort;
    }
    
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    
    public Integer getVisible() {
        return visible;
    }
    
    public void setVisible(Integer visible) {
        this.visible = visible;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
    
    // 重写equals方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        
        Permission that = (Permission) o;
        
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (code != null ? !code.equals(that.code) : that.code != null) return false;
        if (type != null ? !type.equals(that.type) : that.type != null) return false;
        if (parentId != null ? !parentId.equals(that.parentId) : that.parentId != null) return false;
        if (path != null ? !path.equals(that.path) : that.path != null) return false;
        if (method != null ? !method.equals(that.method) : that.method != null) return false;
        if (icon != null ? !icon.equals(that.icon) : that.icon != null) return false;
        if (sort != null ? !sort.equals(that.sort) : that.sort != null) return false;
        if (visible != null ? !visible.equals(that.visible) : that.visible != null) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        return updateTime != null ? updateTime.equals(that.updateTime) : that.updateTime == null;
    }
    
    // 重写hashCode方法
    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (code != null ? code.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
        result = 31 * result + (path != null ? path.hashCode() : 0);
        result = 31 * result + (method != null ? method.hashCode() : 0);
        result = 31 * result + (icon != null ? icon.hashCode() : 0);
        result = 31 * result + (sort != null ? sort.hashCode() : 0);
        result = 31 * result + (visible != null ? visible.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        return result;
    }
}